package com.szjlxh.data.entity;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * Created by liutao on 16/3/13.
 */
public class WeatherBaseBean {

    /**
     * STATIONID : 58238
     * DDATETIME : 2016-03-13 14:20:00.0
     * LAST_UPDATE : 2016-03-13 22:20:00.0
     * LAT : 31.93
     * LON : 118.9
     * TEMP : 7.6
     * MAX_TEMP : 7.9
     * MIN_TEMP : 7.6
     * HUMIDITY : 76
     * HOUR_RAIN : 0
     * WIND_DIRECTION : 15
     * WIND_SPEED : 1.1
     * VISIBILITY : 2061
     * WEATHERCODE : 00
     * PM25 : 67
     * FEELTEMP : -1
     * WIND_DIRECTIONNAME : 东北风
     * WEATHERNAME : 晴
     */

    private List<ResultEntity> result;

    public void setResult(List<ResultEntity> result) {
        this.result = result;
    }

    public List<ResultEntity> getResult() {
        return result;
    }

    public static class ResultEntity {
        private String STATIONID;
        private String DDATETIME;
        private String LAST_UPDATE;
        private String LAT;
        private String LON;
        private String TEMP;
        private String MAX_TEMP;
        private String MIN_TEMP;
        private String HUMIDITY;
        private String HOUR_RAIN;
        private String WIND_DIRECTION;
        private String WIND_SPEED;
        private String VISIBILITY;
        private String WEATHERCODE;
        private String PM25;
        private String FEELTEMP;
        private String WIND_DIRECTIONNAME;
        private String WEATHERNAME;

        public void setSTATIONID(String STATIONID) {
            this.STATIONID = STATIONID;
        }

        public void setDDATETIME(String DDATETIME) {
            this.DDATETIME = DDATETIME;
        }

        public void setLAST_UPDATE(String LAST_UPDATE) {
            this.LAST_UPDATE = LAST_UPDATE;
        }

        public void setLAT(String LAT) {
            this.LAT = LAT;
        }

        public void setLON(String LON) {
            this.LON = LON;
        }

        public void setTEMP(String TEMP) {
            this.TEMP = TEMP;
        }

        public void setMAX_TEMP(String MAX_TEMP) {
            this.MAX_TEMP = MAX_TEMP;
        }

        public void setMIN_TEMP(String MIN_TEMP) {
            this.MIN_TEMP = MIN_TEMP;
        }

        public void setHUMIDITY(String HUMIDITY) {
            this.HUMIDITY = HUMIDITY;
        }

        public void setHOUR_RAIN(String HOUR_RAIN) {
            this.HOUR_RAIN = HOUR_RAIN;
        }

        public void setWIND_DIRECTION(String WIND_DIRECTION) {
            this.WIND_DIRECTION = WIND_DIRECTION;
        }

        public void setWIND_SPEED(String WIND_SPEED) {
            this.WIND_SPEED = WIND_SPEED;
        }

        public void setVISIBILITY(String VISIBILITY) {
            this.VISIBILITY = VISIBILITY;
        }

        public void setWEATHERCODE(String WEATHERCODE) {
            this.WEATHERCODE = WEATHERCODE;
        }

        public void setPM25(String PM25) {
            this.PM25 = PM25;
        }

        public void setFEELTEMP(String FEELTEMP) {
            this.FEELTEMP = FEELTEMP;
        }

        public void setWIND_DIRECTIONNAME(String WIND_DIRECTIONNAME) {
            this.WIND_DIRECTIONNAME = WIND_DIRECTIONNAME;
        }

        public void setWEATHERNAME(String WEATHERNAME) {
            this.WEATHERNAME = WEATHERNAME;
        }

        public String getSTATIONID() {
            return STATIONID;
        }

        public String getDDATETIME() {
            return DDATETIME;
        }

        public String getLAST_UPDATE() {
            return LAST_UPDATE;
        }

        public String getLAT() {
            return LAT;
        }

        public String getLON() {
            return LON;
        }

        public String getTEMP() {
            return TEMP;
        }

        public String getMAX_TEMP() {
            return MAX_TEMP;
        }

        public String getMIN_TEMP() {
            return MIN_TEMP;
        }

        public String getHUMIDITY() {
            return HUMIDITY;
        }

        public String getHOUR_RAIN() {
            return HOUR_RAIN;
        }

        public String getWIND_DIRECTION() {
            return WIND_DIRECTION;
        }

        public String getWIND_SPEED() {
            return WIND_SPEED;
        }

        public String getVISIBILITY() {
            return VISIBILITY;
        }

        public String getWEATHERCODE() {
            return WEATHERCODE;
        }

        public String getPM25() {
            return PM25;
        }

        public String getFEELTEMP() {
            return FEELTEMP;
        }

        public String getWIND_DIRECTIONNAME() {
            return WIND_DIRECTIONNAME;
        }

        public String getWEATHERNAME() {
            return WEATHERNAME;
        }

        public String getFormatVisibility() {
            int distance = Integer.valueOf(this.VISIBILITY);
            if (distance>=1000) {
                return distance/1000+"km";
            }
            return distance+"m";
        }

        public String getFormatUpdateDate() {
            SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd HH:mm:ss.SSS");
            try {
                Date date = format.parse(this.DDATETIME);
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(date);
//                return date.getDay()+"日"+date.getHours()+":"+date.getMinutes()+"更新";
                return calendar.get(Calendar.DAY_OF_MONTH)+"日 "+calendar.get(Calendar.HOUR_OF_DAY)+":"+calendar.get(Calendar.MINUTE)+"更新";
            } catch (ParseException e) {
                e.printStackTrace();
                return this.DDATETIME;
            }
        }
    }
}
